home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-23 | 3.8 KB | 171 lines | [TEXT/PJMM] |
- program Main;
-
- { This program was written by Peter Lewis, Aug 1991 in THINK Pascal 3.0.2 }
- { To compile it you will need the System 7 versions of the Interface files }
- { Set Project Type to Application APPL/PnLh, has bundle}
- { Set Run Options to Use Resource File DeHQX.rsrc}
- { Set the project to include -}
- {Interfaces:}
- { FixMath.p}
- { Types.p}
- { OSUtils.p}
- { Files.p}
- { Dialogs.p}
- { StandardFile.p}
- { AppleTalk.p}
- { Aliases.p}
- { Notification.p}
- { PPCToolBox.p}
- { Processes.p}
- { EPPC.p}
- { AppleEvents.p}
- { Folders.p}
- { GestaltEqu.p}
- { Traps.p}
- { Ballons.p}
- {CRC Object module:}
- { CalcCRC.a.o}
- {My Libraries:}
- { MyTypes.unit}
- { MyLists.unit}
- { MyUtilities.unit}
- { MyAppleEvents.unit}
- { MyNotifier.unit}
- { MySystem7.unit}
- { MyMainLoop.unit}
- { MyFileSystem.unit}
- { MyStandardFile.unit}
- { MyMenus.unit}
- {DeHQX Files:}
- { AppGlobals.p}
- { Preferences.p}
- { DoMenus.p}
- { SmallEvents.p}
- { CRCs.p}
- { HQXLists.p}
- { Displays.p}
- { ReadHQX.p}
- { DisplayHQX.p}
- { DeHQX.p}
- { Main.p}
- { Then turn off the Debug switche }
-
- uses
- MyMainLoop, DoMenus, Types, OSUtils, Files, MyMenus, MyUtilities, MyFileSystem, MyLists, {}
- MyTypes, MyAppleEvents, MySystem7, AppGlobals, SmallEvents, HQXLists, ReadHQX, DeHQX,{}
- Preferences, MyNotifier;
-
- var
- launched_with_option: boolean;
-
- function DoOApp: OSErr;
- begin
- if prefs.drop_folder and not launched_with_option then begin
- AddFolder(prefs.drop_vrn, prefs.drop_dirID);
- end;
- if prefs.startup_state and in_foreground and not AnyInputFiles then
- { Messy if we have got into the background already! So I just avoid it :-) }
- DeHQXFiles;
- DoOApp := noErr;
- end;
-
- function DoODoc (fs: FSSpec): OSErr;
- var
- pb: CInfoPBRec;
- oe: OSErr;
- begin
- with pb do begin
- ioNamePtr := @fs.name;
- ioVRefNum := fs.vRefNum;
- ioDirID := fs.parID;
- ioFDirIndex := 0;
- end;
- oe := PBGetCatInfo(@pb, false);
- if oe = noErr then begin
- if BAND(pb.ioFlAttrib, $0010) = 0 then
- AddFile(fs.vRefNum, fs.parID, fs.name, prefs.create_dir_state = CDS_Always, pb.ioFlLgLen)
- else
- AddFolder(fs.vRefNum, pb.ioDirID);
- end;
- DoODoc := oe;
- end;
-
- function DoQuit: OSErr;
- begin
- quitNow := true;
- DoQuit := noErr;
- end;
-
- var
- er: eventRecord;
- reply: HEreply;
- s: str255;
- sh: stringHandle;
- paramCount, paramMessage, i: integer;
- af: appFile;
- doparams: boolean;
- oe: OSErr;
- dummyb: boolean;
- begin
- dummyb := GetOSEvent(0, er);
- launched_with_option := BAND(er.modifiers, optionKey) <> 0;
- InitNotify;
- InitUtilities;
- if not has_AppleEvents then begin
- CountAppFiles(paramMessage, paramCount);
- if paramMessage <> appOpen then { Must be Open, not Print! }
- begin
- SysBeep(10);
- halt;
- end;
- end;
- InitReadHQX;
- InitPreferences;
- doparams := false;
- if not has_AppleEvents then
- for i := 1 to paramCount do begin
- GetAppFiles(i, af);
- with af do
- if fType = myAppType then begin
- GetPreferences(vRefNum, 0, fName);
- ClrAppFiles(i);
- end
- else
- doparams := true;
- end;
- InitMainLoop;
- InitMenus(@DeHQXFiles);
- InitCursor;
-
- SetMenus;
-
- if not has_AppleEvents and prefs.drop_folder and not launched_with_option then begin
- AddFolder(prefs.drop_vrn, prefs.drop_dirID);
- end;
-
- if has_AppleEvents then
- oe := InitAppleEvents(@DoOApp, @DoODoc, nil, @DoQuit)
- else begin
- if doparams then begin
- DeHQXParameters;
- end { don't Auto DeHQX… or Drop Folder if any documents are double-clicked }
- else if prefs.startup_state then begin
- if prefs.drop_folder and not launched_with_option then begin
- AddFolder(prefs.drop_vrn, prefs.drop_dirID);
- end;
- if not AnyInputFiles then { Don't Auto DeHQX… if Drop Folder }
- DeHQXFiles;
- end;
- end;
- while not quitNow do begin
- DeHQXList; { DeHQX any files that nead dehqxing }
- if not quitNow then
- HandleMainEvents(maxlongInt, nil, reply);
- if quitNow then
- quitNow := not FinishPreferences;
- end;
-
- FinishMainLoop;
- FinishReadHQX;
- FinishNotify;
- end.